﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Data.SqlClient;

using EHTSaleManager.Code;
using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Utility;
using EHTSaleManager.Code.Entity;

namespace EHTSaleManager
{
    public partial class IndexNews : System.Web.UI.Page
    {
        private int NewsID = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                NewsID = Int32.Parse(Request.QueryString["NewsID"].ToString());
            }
            catch (Exception ex) {
                NewsID = -1;
            }
            if (!Page.IsPostBack)
            {
                LoadData(NewsID);
            }
        }

        public void LoadData(int newsID)
        {
            if (NewsID != -1)
            {
                dtlNews.DataSource = NewsProvider.GetDetailsNewsByNewsID(newsID);
                dtlNews.DataBind();
            }
            else
            {
                dtlNews.DataSource = NewsProvider.GetNews();
                dtlNews.DataBind();
            }
        }
    }
}